package starter.context;

import java.util.Map;

import com.bowlong.concurrent.async.Async;
import com.bowlong.util.MapEx;

@SuppressWarnings("unchecked")
public class GameContext {
	final Map<String, Object> map;

	public GameContext() {
		this.map = MapEx.getMap(App.ctx(), "game");

		this.id = MapEx.getInt(map, "id");
		this.name = MapEx.getString(map, "name");
		this.host = MapEx.getString(map, "host");
		this.port = MapEx.getInt(map, "port");
		this.httpPort = MapEx.getInt(map, "httpPort");
		this.manaPort = MapEx.getInt(map, "manaPort");
		this.shutdownPort = MapEx.getInt(map, "shutdownPort");
		this.key = MapEx.getString(map, "key");
		this.gateHost = MapEx.getString(map, "gateHost");
		this.gatePort = MapEx.getInt(map, "gatePort");
		this.lowestVer = MapEx.getString(map, "lowestVer");
		this.nowVer = MapEx.getString(map, "nowVer");
	}

	public final int id;
	public final String name;
	public final String host;
	public final int port;
	public final int httpPort;
	public final int manaPort;
	public final int shutdownPort;
	public final String key;
	public final String gateHost;
	public final int gatePort;
	public final String lowestVer;
	public final String nowVer;

	public static void loadAll() throws Exception {
		// init thread pool
		Async.init(1, 4);
	}
}
